#include <REGX52.h>
#include <INTRINS.h>
#include "Timer.h"
#include "SoleKey.h"

unsigned int timeCount = 0, mode = 0, keyNum = 0;
/**
  * @brief  根据独立按键改变LED流水灯的方向
  * @parm	无
  * @retval 无
  */
void Timer0_Routine(void) interrupt 1
{
	//注意每次中断都要初始化定时值
	TH0 = 64535 / 255;		//高8位
	TL0 = 64535 % 255;		//低8位
	timeCount++;
	if(timeCount >= 1000)
	{
		timeCount = 0;
		if(mode == 0)//模式一，LED向右
			P2 = _crol_(P2, 1);
		else//模式二，LED向左
			P2 = _cror_(P2, 1);
	}
}

  
void main()
{
	Timer0Init();
	P2 = 0xFE;//初始化LED灯为只有D1亮
    while(1)
    {
        keyNum = soleKey();
		if(keyNum == 1)
		{
			mode++;
			if(mode >= 2)	
				mode = 0;
		}
    }
}
